<style lang="less">
    @import "loanFlawFix.less";
</style>
<template>
    <div class="search">
        <div style="width:100%;overflow:hidden;margin-bottom: -10px;">
            <div style="display:inline-block;float:left;width:98%;text-align:right">
                <Button type="primary" @click="backGo">返回</Button>
                <Button type="primary" @click="pauseBtn">暂存</Button>&nbsp;
                <Button type="primary" @click="fraudFeedback">提交</Button>
            </div>
        </div>
        <Row>
            <div class="with_lineTitle">
                　　<span class="line"></span>
                　　<span class="Tbox">放款申请修正反馈</span>
                　　<span class="line"></span>
            </div>
        </Row>
        <Row>
            <Col>
                <Card>
                    <Row>
                        <Form ref="searchForm" :model="searchForm" inline :label-width="100" class="search-form">
                            <Form-item label="修正类型" prop="correctionType">
                                <Select v-model="searchForm.correctionType" clearable placeholder="请选择" style="width:200px">
                                    <Option v-for="item in this.dicKeysList.flawTypeList" :label="item.title" :value="item.value" :key="item.value">{{item.title}}</Option>
                                </Select>
                            </Form-item>
                            <Form-item label="申请标号" prop="applyNo">
                                <Input v-model="searchForm.applyNo" type="text" icon="ios-search-outline" @on-click="findByApplyNo" placeholder="请输入" style="width:200px"/>
                            </Form-item>
                            <Form-item label="客户姓名" prop="custNameRepeat">
                                <Input type="text" v-model="searchForm.custNameRepeat" disabled placeholder="根据申请编号带出" style="width: 200px" />
                            </Form-item>
                            <Form-item label="证件号码" prop="certNoRepeat">
                                <Input type="text" v-model="searchForm.certNoRepeat" disabled placeholder="根据申请编号带出" style="width: 200px" />
                            </Form-item>
                            <Form-item label="合作商名称" prop="dealerName">
                                <Input type="text" v-model="searchForm.dealerName" disabled placeholder="根据申请编号带出" style="width: 200px" />
                            </Form-item>
                            <Form-item label="业务分类" prop="businessType">
                                <Input type="text" v-model="searchForm.businessType" disabled placeholder="根据申请编号带出" style="width: 200px" />
                            </Form-item>
                            <Form-item label="案件状态"  prop="applyStatus">
                                <Input type="text" v-model="searchForm.applyStatus" disabled placeholder="根据申请编号带出" style="width: 200px" />
                            </Form-item>
                            <Form-item label="放款审核通过时间" prop="passLastDate">
                                <Input type="text" v-model="searchForm.passLastDate" disabled placeholder="根据申请编号带出" style="width: 200px" />
                            </Form-item>
                            <Form-item label="合同激活时间" prop="ledingPassDate">
                                <Input type="text" v-model="searchForm.ledingPassDate" disabled placeholder="根据申请编号带出" style="width: 200px" />
                            </Form-item>
                        </Form>
                    </Row>
                </Card>
            </Col>
        </Row>
        <Row>
            <div class="with_lineTitle">
                　　<span class="line"></span>
                　　<span class="Tbox">修正内容</span>
                　　<span class="line"></span>
            </div>
        </Row>
        <Row>
            <Col>
                <Card>
                    <Row>
                        <Form ref="searchForm" :model="detailSearchForm" inline :label-width="100" class="search-form">
                            <Form-item label="修正文件类型" prop="applyNo">
<!--                                <Select v-model="detailSearchForm.fileType" clearable placeholder="请选择" style="width:200px">-->
<!--                                    <Option v-for="item in fileTypeNameData" :label="item.attachmentName" :value="item.attachmentId" :key="item.attachmentName">{{item.attachmentName}}</Option>-->
<!--                                </Select>-->
                                <Cascader :data="fileTypeNameData" @on-change="onChangeFileType" placeholder="请选择" :clearable="false">
                                </Cascader>
                            </Form-item>
                            <Form-item label="问题描述" prop="dealerName">
                                <Input v-model="detailSearchForm.problemDesc" type="textarea" placeholder="请输入" style="width:600px"/>
                            </Form-item>
                            <Form-item style="margin-left: -35px;">
                                <Button @click="addBtn" type="primary">添加</Button>
                            </Form-item>
                        </Form>
                    </Row>
                    <Row>
                        <Table v-bind:loading="loading"
                               border
                               v-bind:columns="columns"
                               v-bind:data="data"
                               sortable="custom"
                               @on-sort-change="changeSort"
                               @on-selection-change="showSelect"
                               :row-class-name="rowClassName"
                               ref="table">
                            <template slot-scope="{row,index}" slot="action">
                                <span v-if="row.flawApplyStatus=='draft'">
                                    <Button style="margin-right:5px" type="error" size="small" @click="delFlawFix(row)">删除</Button>
                                </span>
                                <span v-if="row.flawApplyStatus!='draft'">
                                    <Button style="margin-right:5px" disabled type="error" size="small" @click="delFlawFix(row)">删除</Button>
                                </span>
                                <Button style="margin-right:5px" type="primary" size="small" @click="showFlawFix(row)">查看</Button>
                            </template>
                            <template slot-scope="{row , index}" slot="flawApplyStatus">
                                <span>{{setFlawApplyStatus(row.flawApplyStatus)}}</span>
                            </template>
                            <template slot-scope="{row , index}" slot="correctionType">
                                <span>{{setCorrectionType(row.correctionType)}}</span>
                            </template>
                        </Table>
                    </Row>
                </Card>
            </Col>
        </Row>
    </div>
</template>

<script>
    import {findParamsByApplyNo,getFileTypeList} from '@/projects/afs-core-business/api/afs-case/loan-flaw-fix/loanFlawFix';
    export default {
        name: "addLoanFlawFix",
        props:{
            dicKeysList:{},
        },
        data(){
            return{
                loading:false,
                fileTypeNameData:[],
                searchForm:{
                    applyNo:'',
                    correctionType:'',
                    custNameRepeat:'',
                    certNoRepeat:'',
                    dealerName:'',
                    businessType:'',
                    applyStatus:'',
                    passLastDate:'',
                    ledingPassDate:''
                },
                detailSearchForm:{
                    fileType:'',
                    problemDesc:''
                },
                columns:[],
                data:[],
            }
        },
        mounted(){
          this.init();
        },
        methods: {
            init(){
              this.getFileTypeList();
            },
            findByApplyNo(){
                findParamsByApplyNo(this.searchForm).then(res=>{
                    if(res.code==='0000'){
                        this.searchForm = res.data;
                        console.log(res.data)
                        let businessType = {}
                        this.dicKeysList.businessTypeList.forEach(colunm => {
                            if (colunm.value === res.data.businessType) {
                                businessType = colunm
                            }
                        })
                        this.searchForm.businessType = businessType.title
                        let conApplyStatus= {}
                        this.dicKeysList.conApplyStatusList.forEach(colunm => {
                            if (colunm.value === res.data.applyStatus) {
                                conApplyStatus = colunm
                            }
                        })
                        this.searchForm.applyStatus = conApplyStatus.title
                    }
                }).catch(e => {
                    this.searchForm = {
                        applyNo:'',
                        correctionType:'',
                        custNameRepeat:'',
                        certNoRepeat:'',
                        dealerName:'',
                        businessType:'',
                        applyStatus:'',
                        passLastDate:'',
                        ledingPassDate:''
                    }
                });
            },
            addBtn(){

            },
            backGo(){
                this.$emit('backGo');
            },
            pauseBtn(){

            },
            fraudFeedback(){

            },
            changeSort(){

            },
            showSelect(){

            },
            rowClassName(){

            },
            onChangeFileType(val){
                this.detailSearchForm.fileType = val;
            },
            delFlawFix(val){
                console.log(val)
                this.$Modal.confirm({
                    title: "确认删除",
                    content: "您确认要删除该条数据?",
                    onOk: () => {
                        this.searchForm.id = val.id;
                        this.operationLoading = true;
                        delFlawFix(this.searchForm).then(res => {
                            this.operationLoading = false;
                            if (res.code === "0000") {
                                this.$Message.success("删除成功");
                                this.getLoanFlawFixList();
                            }
                        });
                    }
                })
            },
            showFlawFix(){},
            getFileTypeList(){
                this.loading=true;
                getFileTypeList(this.loanBackReasonParams).then(res =>{
                    this.loading=false;
                    this.fileTypeNameData=res.data;
                })
            },
        }
    }
</script>

<style scoped>
</style>
